package com.sqfw.project.wpReport.service.impl;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;

import com.github.pagehelper.PageInfo;
import com.sqfw.common.constant.HttpStatus;
import com.sqfw.common.utils.StringUtils;
import com.sqfw.framework.aspectj.lang.annotation.DataSource;
import com.sqfw.framework.aspectj.lang.enums.DataSourceType;
import com.sqfw.framework.web.page.TableDataInfo;
import com.sqfw.project.system.domain.SysUser;
import com.sqfw.project.system.mapper.SysUserMapper;
import com.sqfw.project.wp.domain.WpInfo;
import com.sqfw.project.wp.mapper.WpInfoCallMapper;
import com.sqfw.project.wp.mapper.WpInfoMapper;
import com.sqfw.project.wpReport.domain.SeatWpInfo;
import com.sqfw.project.wpReport.domain.dto.NoLinkDTO;
import com.sqfw.project.wpReport.domain.dto.WpInfoCallDTO;
import com.sqfw.project.wpReport.domain.dto.YuyinDTO;
import com.sqfw.project.wpReport.mapper.YuyinMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.sqfw.project.wpReport.domain.SeatServiceReport;
import com.sqfw.project.wpReport.service.ISeatServiceReportService;


/**
 * 话务员服务满意度评测统计表Service业务层处理
 *
 * @author lx
 * @date 2023-08-01
 */
@Service
@Slf4j
public class SeatServiceReportServiceImpl implements ISeatServiceReportService {

    @Autowired
    private WpInfoCallMapper wpInfoCallMapper;

    @Autowired
    private WpInfoMapper wpInfoMapper;

    @Autowired
    private YuyinMapper yuyinMapper;

    @Autowired
    @Qualifier(value = "asyncServiceExecutor")
    private Executor executor;

    @Autowired
    private SysUserMapper sysUserMapper;



    @Override
    public TableDataInfo getSeatServiceReportList(YuyinDTO yuyinDto, List<YuyinDTO> rows) {
        WpInfo wpInfo = wpInfoMapper.selectWpInfoByScid("1001");
        //主要用于分页条件
        //根据每天统计
        TableDataInfo tableDataInfo = new TableDataInfo();



        if ("day".equals(yuyinDto.getDateType())) {
           /* List<WpInfoCallDTO> dtos = wpInfoCallMapper.getSeatServiceReportList(seatServiceReport);
            tableDataInfo.setTotal(new PageInfo(dtos).getTotal());
*/
            //SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

           //log.info("按天返回语音数据：{}",rows);
            //创建异步阻塞任务集合
            List<CompletableFuture<SeatServiceReport>> futureList = new ArrayList<>();
            for (YuyinDTO yuyin : rows) {
                SysUser sysUser = sysUserMapper.selectUserByCode(yuyin.getAgentId());

                WpInfoCallDTO dto = new WpInfoCallDTO();
                dto.setCountDate(yuyin.getTime());
                dto.setNickName(sysUser.getNickName());
                dto.setCode(yuyin.getAgentId());
                dto.setBegainTime(yuyinDto.getBegainTime());
                dto.setEndTime(yuyinDto.getEndTime());
                dto.setTotal(yuyin.getTotal());
                dto.setConnectingCount(yuyin.getConnectingCount());
                futureList.add(CompletableFuture.supplyAsync(() -> getSeatServiceReportByDayFutule(dto), executor));

            }

            //等待所有任务执行完成
            CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0]));
            List<SeatServiceReport> collect = futureList.stream().map(CompletableFuture::join).collect(Collectors.toList());
           // reports.addAll(collect);
            List<SeatServiceReport> seatServiceReports = collect.stream().sorted(Comparator.comparing(SeatServiceReport::getTotalCount).reversed()).collect(Collectors.toList());
            int creatCountAll = seatServiceReports.stream()
                    .map(SeatServiceReport::getCreatCount)
                    .reduce(Integer::sum)
                    .orElse(0);
            for (SeatServiceReport serviceReport : seatServiceReports) {
                Integer creatCount = serviceReport.getCreatCount();
                if (creatCountAll > 0) {
                    double v = (double) creatCount / (double) creatCountAll;

                    BigDecimal value1 = new BigDecimal(v * 100).setScale(2, BigDecimal.ROUND_HALF_UP);
                    serviceReport.setCountKK(value1+"%");
                }else {
                    serviceReport.setCountKK("0.00%");
                }
            }
            tableDataInfo.setMsg("查询成功");
            tableDataInfo.setCode(HttpStatus.SUCCESS);
            tableDataInfo.setRows(seatServiceReports);
        }
        //根据月份统计
        if ("month".equals(yuyinDto.getDateType())) {
            /*List<WpInfoCallDTO> dtos = wpInfoCallMapper.getSeatServiceReportListByMonth(seatServiceReport);
            tableDataInfo.setTotal(new PageInfo(dtos).getTotal());*/
           // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");


          //  log.info("按月返回语音数据：{}",rows);
          /*  yuyinDto.setTimeEnd(seatServiceReport.getEndTime());
            yuyinDto.setTimeStart(seatServiceReport.getBegainTime());*/


            //创建异步阻塞任务集合
            List<CompletableFuture<SeatServiceReport>> futureList = new ArrayList<>();
            for (YuyinDTO yuyin : rows) {
                SysUser sysUser = sysUserMapper.selectUserByCode(yuyin.getAgentId());

                WpInfoCallDTO dto = new WpInfoCallDTO();
                dto.setCountDate(yuyin.getTime());
                dto.setNickName(sysUser.getNickName());
                dto.setCode(yuyin.getAgentId());
                dto.setBegainTime(yuyinDto.getBegainTime());
                dto.setEndTime(yuyinDto.getEndTime());
                dto.setTotal(yuyin.getTotal());
                dto.setConnectingCount(yuyin.getConnectingCount());
                futureList.add(CompletableFuture.supplyAsync(() -> getSeatServiceReportByMonthFutule(dto), executor));



            }
            //等待所有任务执行完成
            CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0]));
            List<SeatServiceReport> collect = futureList.stream().map(CompletableFuture::join).collect(Collectors.toList());
            //reports.addAll(collect);

            List<SeatServiceReport> seatServiceReports = collect.stream().sorted(Comparator.comparing(SeatServiceReport::getTotalCount).reversed()).collect(Collectors.toList());

            int creatCountAll = seatServiceReports.stream()
                    .map(SeatServiceReport::getCreatCount)
                    .reduce(Integer::sum)
                    .orElse(0);
            for (SeatServiceReport serviceReport : seatServiceReports) {
                Integer creatCount = serviceReport.getCreatCount();
                if (creatCountAll > 0) {
                    double v = (double) creatCount / (double) creatCountAll;

                    BigDecimal value1 = new BigDecimal(v * 100).setScale(2, BigDecimal.ROUND_HALF_UP);
                    serviceReport.setCountKK(value1+"%");
                }else {
                    serviceReport.setCountKK("0.00%");
                }
            }
            tableDataInfo.setMsg("查询成功");
            tableDataInfo.setCode(HttpStatus.SUCCESS);
            tableDataInfo.setRows(seatServiceReports);
        }
        return tableDataInfo;
    }

    private SeatServiceReport getSeatServiceReportByMonthFutule(WpInfoCallDTO dto) {


        SeatServiceReport report = new SeatServiceReport();
        report.setNickName(dto.getNickName());
        report.setCountDate(dto.getCountDate());
        report.setCode(dto.getCode());
        //开始结束时间
        /*dto.setBegainTime(seatServiceReport.getBegainTime());
        dto.setEndTime(seatServiceReport.getEndTime());*/
        report.setOutCount(dto.getTotal());

        //查询呼出成功量
        report.setOutSucessCount(dto.getConnectingCount());
        WpInfo infoCon = new WpInfo();
        infoCon.setCountDate(report.getCountDate());
        infoCon.setSender(dto.getCode());

        //12345建单量
        int creatCount = wpInfoMapper.creatCountByMoth(infoCon);

        List<String> wpids = wpInfoMapper.creatCountWpidsByMoth(infoCon);

        report.setCreatCount(creatCount);

        Integer countA = wpInfoMapper.countAByMoth(infoCon);

        //工单内，联系电话1或2的电话为0的工单
        report.setCountA(countA);

        dto.setClass1("13553");
        dto.setWpids(wpids);
        //满意
        dto.setSatisfaction("满意");
        Integer countB = wpInfoCallMapper.countWpInfoCallGroupBySatisByMonth(dto);
        report.setCountB(countB);
        //一般
        dto.setSatisfaction("一般");
        Integer countC = wpInfoCallMapper.countWpInfoCallGroupBySatisByMonth(dto);
        report.setCountC(countC);
        //不满意
        dto.setSatisfaction("不满意");
        Integer countD = wpInfoCallMapper.countWpInfoCallGroupBySatisByMonth(dto);
        report.setCountD(countD);

        //工单来源为12345的已按满意度测评的工单已测评
//        Integer countE = wpInfoMapper.countEByMoth(infoCon);
//        report.setCountE(countE);

        //工单来源为12345的已按满意度测评的工单未测评
        Integer countF2 = wpInfoMapper.countFByMoth2(infoCon);
        Integer countF = wpInfoMapper.countFByMoth(infoCon);
        // 总-已经评价满意度的
        report.setCountF(countF2 - countF);

        dto.setClass1("13554");
        dto.setClass2("18359");
        //满意
        dto.setSatisfaction("满意");
        Integer countG = wpInfoCallMapper.countWpInfoCallGroupBySatisByMonth(dto);
        report.setCountG(countG);
        //一般
        dto.setSatisfaction("一般");
        Integer countH = wpInfoCallMapper.countWpInfoCallGroupBySatisByMonth(dto);
        report.setCountH(countH);
        //不满意
        dto.setSatisfaction("不满意");
        Integer countI = wpInfoCallMapper.countWpInfoCallGroupBySatisByMonth(dto);
        report.setCountI(countI);
        dto.setSatisfaction(null);

        //电话0退单
        Integer phoneBackCount = wpInfoMapper.countPhoneBackByMoth(infoCon);
        report.setCountJ(phoneBackCount);

        List<NoLinkDTO> noLinkDTOS = wpInfoMapper.countNoLinkByMoth(infoCon);
        //未联系退单
        long countK = noLinkDTOS.stream().filter(noLinkDTO -> !"out".equals(noLinkDTO.getCallDirection())).count();
        report.setCountK((int) countK);

        //Integer countL = wpInfoMapper.countLByMoth(infoCon);
        //已测评退单
        //report.setCountL(countL);
        //列表展示满意
        report.setCountAA(report.getCountB() + report.getCountG());

        //列表展示一般
        report.setCountBB(report.getCountC() + report.getCountH());

        //列表展示不满意
        report.setCountCC(report.getCountD() + report.getCountI());

        //列表展示退单总量
        report.setCountDD(report.getCountG() + report.getCountH() + report.getCountI() + report.getCountJ() + report.getCountK());

        //市民参评总量
        report.setCountEE(report.getCountAA() + report.getCountBB() + report.getCountCC());

        //0电话及退单未参评

        report.setCountFF(report.getCountA() + report.getCountJ() + report.getCountK());
        //实际未参评
        report.setCountGG(report.getCountF());

        //话务员参评总量
        report.setCountHH(report.getCountAA() + report.getCountBB() + report.getCountCC()
                + report.getCountF()  + report.getCountFF());
//        int countHH = wpInfoMapper.countHHByMoth(infoCon);
//        report.setCountHH(countHH);
        //话务员参评总量/(12345建单量-0电话及退单未参评)
        if (report.getCreatCount() - report.getCountJ() > 0) {
            double i = (double) report.getCountHH() / (double) (report.getCreatCount() - report.getCountJ());
            BigDecimal value1 = new BigDecimal(i * 100).setScale(2, BigDecimal.ROUND_HALF_UP);

            report.setCountII(value1 + "%");
        } else {
            report.setCountII("0.00%");
        }

        //满意*100分+一般*60分+不满意0分/市民参评总量
        if (report.getCountEE() > 0) {
            double v = (double) (report.getCountAA() + report.getCountBB() * 0.6) / (double) report.getCountEE();
            BigDecimal value1 = new BigDecimal(v * 100).setScale(2, BigDecimal.ROUND_HALF_UP);
            report.setCountJJ(value1 + "%");
        } else {
            report.setCountJJ("0.00%");
        }


        //12345建单量/搜索日期总计值

        //12345建单量
       /* int creatAllCount = wpInfoMapper.creatAllCountByMoth(infoCon);


        if (creatAllCount > 0) {
            double v = (double) report.getCreatCount() / (double) creatAllCount;

            BigDecimal value1 = new BigDecimal(v * 100).setScale(2, BigDecimal.ROUND_HALF_UP);
            report.setCountKK(value1+"%");
        }else {
            report.setCountKK("0.00%");
        }*/
        //参评率得分
        String countII = report.getCountII();
        if (StringUtils.isNotEmpty(countII)){
            String[] split = countII.split("%");
            String s = split[0];
            double v = Double.parseDouble(s) * 3;
            BigDecimal value1 = new BigDecimal(v).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
            report.setCountLL(value1.doubleValue());
            // 参评率终得分   话务员参评率大于等于65%按实际得分，低于65%得0分
            if (Double.parseDouble(s) >= 65.00){
                report.setCountMM(value1.doubleValue());
            }else {
                report.setCountMM(0.00);
            }
        }else {
            report.setCountLL(0.00);
            report.setCountMM(0.00);
        }
        // 市民满意率
        String countJJ = report.getCountJJ();
        if (StringUtils.isNotEmpty(countJJ)){
            String[] split = countJJ.split("%");
            String s = split[0];
            double v = Double.parseDouble(s) * 3;
            BigDecimal value1 = new BigDecimal(v).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
            report.setCountPP(value1.doubleValue());
            //满意率得分
            report.setCountNN(value1.doubleValue());
        }else {
            report.setCountNN(0.00);
            report.setCountPP(0.00);
        }

        //总得分
        report.setTotalCount(report.getCountMM()+report.getCountPP());

        return report;
    }

    @DataSource(value = DataSourceType.YUYIN)
    @Override
    public TableDataInfo getYuyinCount(YuyinDTO yuyinDTO) {
        log.info("查询语音通话数据入参：{}",yuyinDTO);
        List<YuyinDTO> yuyinDTOS = yuyinMapper.countYuyin(yuyinDTO);
        log.info("查询语音通话数据返回：{}",yuyinDTOS);
        return getDataTable(yuyinDTOS);

    }


    private SeatServiceReport getSeatServiceReportByDayFutule(WpInfoCallDTO dto) {

        SeatServiceReport report = new SeatServiceReport();
        report.setNickName(dto.getNickName());
        report.setCountDate(dto.getCountDate());
        report.setCode(dto.getCode());
        //开始结束时间
        /*dto.setBegainTime(seatServiceReport.getBegainTime());
        dto.setEndTime(seatServiceReport.getEndTime());*/

        //查询呼出总量

        //查询呼出总量
       /* YuyinDTO yuyinDTO = new YuyinDTO();
        yuyinDTO.setTimeStart(seatServiceReport.getBegainTime());
        yuyinDTO.setTimeEnd(seatServiceReport.getEndTime());
        yuyinDTO.setType("1");
        yuyinDTO.setAgentId(dto.getCode());
        YuyinDTO yuyinDto = this.getYuyinCount(yuyinDTO);*/

        //int outCount = wpInfoCallMapper.getWpInfoCallOutCountByMonth(yuyinDTO);
        report.setOutCount(dto.getTotal());

        //查询呼出成功量
        //int outSucessCount = wpInfoCallMapper.getWpInfoCallOutSucessCountByMonth(dto);
        report.setOutSucessCount(dto.getConnectingCount());

       /* int outCount = wpInfoCallMapper.getWpInfoCallOutCount(dto);
        report.setOutCount(outCount);

        //查询呼出成功量
        int outSucessCount = wpInfoCallMapper.getWpInfoCallOutSucessCount(dto);
        report.setOutSucessCount(outSucessCount);*/


        WpInfo infoCon = new WpInfo();
        infoCon.setCountDate(dto.getCountDate());
        infoCon.setSender(dto.getCode());

        //12345建单量
        int creatCount = wpInfoMapper.creatCount(infoCon);

        report.setCreatCount(creatCount);

        Integer countA = wpInfoMapper.countA(infoCon);

        //工单内，联系电话1或2的电话为0的工单
        report.setCountA(countA);

        dto.setClass1("13553");
        //满意
        dto.setSatisfaction("满意");
        Integer countB = wpInfoCallMapper.countWpInfoCallGroupBySatis(dto);
        report.setCountB(countB);
        //一般
        dto.setSatisfaction("一般");
        Integer countC = wpInfoCallMapper.countWpInfoCallGroupBySatis(dto);
        report.setCountC(countC);
        //不满意
        dto.setSatisfaction("不满意");
        Integer countD = wpInfoCallMapper.countWpInfoCallGroupBySatis(dto);
        report.setCountD(countD);

        //工单来源为12345的已按满意度测评的工单未测评
        Integer countF2 = wpInfoMapper.countF2(infoCon);
        Integer countF = wpInfoMapper.countF(infoCon);
        // 总-已经评价的
        report.setCountF(countF2 - countF);

        dto.setClass1("13554");
        dto.setClass2("18359");

        //满意
        dto.setSatisfaction("满意");
        Integer countG = wpInfoCallMapper.countWpInfoCallGroupBySatis(dto);
        report.setCountG(countG);
        //一般
        dto.setSatisfaction("一般");
        Integer countH = wpInfoCallMapper.countWpInfoCallGroupBySatis(dto);
        report.setCountH(countH);
        //不满意
        dto.setSatisfaction("不满意");
        Integer countI = wpInfoCallMapper.countWpInfoCallGroupBySatis(dto);
        report.setCountI(countI);
        dto.setSatisfaction(null);


        //电话0退单
        Integer phoneBackCount = wpInfoMapper.countPhoneBack(infoCon);
        report.setCountJ(phoneBackCount);

        List<NoLinkDTO> noLinkDTOS = wpInfoMapper.countNoLink(infoCon);
        //未联系退单
        long countK = noLinkDTOS.stream().filter(noLinkDTO -> !"out".equals(noLinkDTO.getCallDirection())).count();
        report.setCountK((int) countK);

       /* Integer countL = wpInfoMapper.countL(infoCon);
        //已测评退单
        report.setCountL(countL);*/
        //列表展示满意
        report.setCountAA(report.getCountB() + report.getCountG());

        //列表展示一般
        report.setCountBB(report.getCountC() + report.getCountH());

        //列表展示不满意
        report.setCountCC(report.getCountD() + report.getCountI());

        //列表展示退单总量
        report.setCountDD(report.getCountG() + report.getCountH() + report.getCountI() + report.getCountJ() + report.getCountK() );

        //市民参评总量
        report.setCountEE(report.getCountAA() + report.getCountBB() + report.getCountCC());

        //0电话及退单未参评

        report.setCountFF(report.getCountA() + report.getCountJ() + report.getCountK());
        //实际未参评
        report.setCountGG(report.getCountF());

        //话务员参评总量
        report.setCountHH(report.getCountAA() + report.getCountBB() + report.getCountCC()
                + report.getCountF());
//        //话务员参评总量
//        int countHH = wpInfoMapper.countHH(infoCon);
//        report.setCountHH(countHH);
       // report.setCountHH(report.getCountEE() + report.getCountE() + report.getCountL());
        //话务员参评总量/(12345建单量-0电话及退单未参评)

        if (report.getCreatCount() - report.getCountJ() > 0) {
            double i = (double) report.getCountHH() / (double) (report.getCreatCount() - report.getCountJ());
            BigDecimal value1 = new BigDecimal(i * 100).setScale(2, BigDecimal.ROUND_HALF_UP);

            report.setCountII(value1 + "%");
        } else {
            report.setCountII("0.00%");
        }

        //满意*100分+一般*60分+不满意0分/市民参评总量
        if (report.getCountEE() > 0) {
            double v = (double) (report.getCountAA() + report.getCountBB() * 0.6) / (double) report.getCountEE();
            BigDecimal value1 = new BigDecimal(v * 100).setScale(2, BigDecimal.ROUND_HALF_UP);
            report.setCountJJ(value1 + "%");
        } else {
            report.setCountJJ("0.00%");
        }


        //12345建单量/搜索日期总计值

        //12345建单量
        /*int creatAllCount = wpInfoMapper.creatAllCount(infoCon);


        if (creatAllCount > 0) {
            double v = (double) report.getCreatCount() / (double) creatAllCount;

            BigDecimal value1 = new BigDecimal(v * 100).setScale(2, BigDecimal.ROUND_HALF_UP);
            report.setCountKK(value1+"%");
        }else {
            report.setCountKK("0.00%");
        }*/
        //参评率得分
        String countII = report.getCountII();
        if (StringUtils.isNotEmpty(countII)){
            String[] split = countII.split("%");
            String s = split[0];
            double v = Double.parseDouble(s) * 3;
            BigDecimal value = new BigDecimal(v).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
            report.setCountLL(value.doubleValue());
            // 参评率终得分   话务员参评率大于等于65%按实际得分，低于65%得0分
            if (Double.parseDouble(s) >= 65.00){
                report.setCountMM(report.getCountLL());
            }else {
                report.setCountMM(0.00);
            }
        }else {
            report.setCountLL(0.00);
            report.setCountMM(0.00);
        }

        //市民满意率
        String countJJ = report.getCountJJ();
        if (StringUtils.isNotEmpty(countJJ)){
            String[] split = countJJ.split("%");
            String s = split[0];
            double v = Double.parseDouble(s) * 3;
            BigDecimal value = new BigDecimal(v).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
            report.setCountPP(value.doubleValue());
            //满意率得分
            report.setCountNN(value.doubleValue());
        }else {
            report.setCountPP(0.00);
            report.setCountNN(0.00);
        }

        //总得分
        report.setTotalCount(report.getCountMM()+report.getCountPP());



        return report;
    }

    @Override
    public List<SeatWpInfo> selectWpInfoSeatService(SeatServiceReport seatServiceReport) {

        //主要用于分页条件
        //根据每天统计
        WpInfoCallDTO dto = new WpInfoCallDTO();
        if (StringUtils.isNotEmpty(seatServiceReport.getCode())) {
            dto.setCode(seatServiceReport.getCode());
        }
        if (StringUtils.isNotEmpty(seatServiceReport.getCountDate())) {
            dto.setCountDate(seatServiceReport.getCountDate());
        }
        List<String> satisfactions = new ArrayList<>();
        satisfactions.add("满意");
        satisfactions.add("一般");
        satisfactions.add("不满意");
        if (satisfactions.contains(seatServiceReport.getSatisfaction())) {
            dto.setSatisfaction(seatServiceReport.getSatisfaction());
        }
        dto.setBegainTime(seatServiceReport.getBegainTime());
        dto.setEndTime(seatServiceReport.getEndTime());
        if ("day".equals(seatServiceReport.getDateType())) {

            List<SeatWpInfo> seatWpInfos = wpInfoCallMapper.selectWpInfoCallOutSucess(dto);
            seatWpInfos.forEach(seatWpInfo -> {
                if (StringUtils.isEmpty(seatWpInfo.getWpid())) {
                    seatWpInfo.setSummary("无关联工单");
                }
            });
            return seatWpInfos;

        }
        //根据月份统计
        if ("month".equals(seatServiceReport.getDateType())) {

            List<SeatWpInfo> seatWpInfos = wpInfoCallMapper.selectWpInfoCallOutSucessByMonth(dto);
            seatWpInfos.forEach(seatWpInfo -> {
                if (StringUtils.isEmpty(seatWpInfo.getWpid())) {
                    seatWpInfo.setSummary("无关联工单");
                }
            });
            return seatWpInfos;

        }


        return new ArrayList<>();
    }

    protected TableDataInfo getDataTable(List<?> list)
    {
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(list);
        rspData.setTotal(new PageInfo(list).getTotal());
        return rspData;
    }
}
